from tkinter import ttk
from tkinter import *


class TkUtils:
    def label(self, master, text, fg, row, column, bg=None):
        return Label(master=master, text=text, font=("Calibri (正文)", 10), fg=fg, bg=bg, padx=5,
                     pady=10).grid(row=row, column=column, sticky=W)

    def labels(self, master, text, fg, x, y, bg=None):
        return Label(master=master, text=text, font=("Calibri (正文)", 10), fg=fg, bg=bg, padx=5,
                     pady=10).place(x=x, y=y)

    def button(self, master, text, fg, x, y, state=None, bg=None, command=None):
        return Button(master=master, text=text, font=("宋体", 10), fg=fg, bg=bg, state=state,
                      command=command).place(x=x, y=y)

    def buttons(self, master, text, fg, row, column, state=None, bg=None, command=None):
        return Button(master=master, text=text, font=("宋体", 10), fg=fg, bg=bg, state=state,
                      command=command).grid(row=row, column=column, sticky=W)

    # 下拉选择框
    def choose_box(self, master, row, column, values, section, option, height=5, width=7):
        choosen = StringVar(master=master)  # #创建变量，便于取值
        com = ttk.Combobox(
            master=master,  # 父容器
            height=height,  # 高度,下拉显示的条目数量
            width=width,  # 宽度
            state="utilonly",  # 设置状态 normal(可选可输入)、utilonly(只可选)、 disabled
            cursor="arrow",  # 鼠标移动时样式 arrow, circle, cross, plus...
            font=("Calibri (正文)", 10),  # 字体
            textvariable=choosen,  # 通过StringVar设置可改变的值
        )  # #创建下拉菜单
        com.grid(row=row, column=column, sticky=W)
        com["value"] = values  # #给下拉菜单设定值

    def text(self, master, height, width, row, column):
        entry_text = StringVar()
        entry = Text(master=master, height=height, width=width)
        entry.grid(row=row, column=column)
